package com.example.qt.ptplatform.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.qt.ptplatform.entity.InviteCode;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface InviteCodeMapper extends BaseMapper<InviteCode> {
    // 查询用户在当前月份生成的邀请码数量
    @Select("SELECT COUNT(*) FROM invite_code WHERE user_id = #{userId} AND month_year = #{monthYear}")
    int countInviteCodesByUserIdAndMonth(@Param("userId") Integer userId, @Param("monthYear") String monthYear);

    // 根据邀请码查询
    @Select("SELECT * FROM invite_code WHERE code = #{code}")
    InviteCode selectByCode(String code);

}
